/** ver: v2 q418
 * @author attilax 老哇的爪�?
	@since  o92 j_48_u$
 */
package com.attilax.ioc;
import aaaCfg.IocX4jobus;

 















import com.attilax.dataService.DataService;
import com.attilax.dataspider.TsaolyoPicSpider;
import com.attilax.db.DBX;
import com.attilax.db.DbxMybatis;
import com.attilax.hre.UrlDslParser;
import com.attilax.io.pathx;
import com.attilax.json.AtiJson;
import com.attilax.lang.Global;
import com.attilax.net.URLEncoder;
import com.attilax.net.UrlEncode_del;
import com.attilax.net.requestImp;
import com.attilax.order.RechargeOrderService;
//import com.attilax.net.UrlEncode;
import com.attilax.persistence.HbxX;
import com.attilax.persistence.PX;
import com.attilax.util.PropX;
import com.attilax.wechat.WeChatPayUtil;
//import com.focustar.ServiceLoctor4vod;
//import com.focustar.downtask.GvDownloadTaskSvs;
import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.name.Names;

 
















import java.util.*;
import java.net.*;
import java.io.*;

import m.global;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.directwebremoting.extend.AbstractCreator;
//import org.directwebremoting.extend.Creator;
/**
 * @author  attilax 老哇的爪�?
 *@since  o92 j_48_u$
 */
public class IocFacV3_iocx_iocutil   {
//	public	static Injector ati;
	
 
	public static void main(String[] args) {
		System.setProperty("cfgfile","pay.ini");
		System.out.println(com.attilax.ioc.Ioc4pay.getBean(RechargeOrderService.class));
		
//		RechargeOrderService ord_srv = IocFacV3_iocx_iocutil
//				.getBean(RechargeOrderService.class);
//		System.out.println("");
//		System.setProperty("prj","jobus");//指明是运行的哪个项目
//	 	DataService dataservice1 = IocFacV3_iocx_iocutil.getBean(DataService.class);
//	 
//	 	
//	 	//设置request实现类到global变量，以便后续程序获取此request对象
//	 	String 	 	sql=URLEncoder.encode("select * from  wxb_good_copy limit 2");
//	 	requestImp ri=new requestImp().setQueryString("$table="+sql+"&$tabletype=sql");
//	 	Global.req.set(ri);
////	 	$tabletype:table(默认) ,其他取�?�sql,view,folder,list等�??
//	 	//$op：select(默认),update,delete
//	 	//$where 
//	 	
//	 	List<Map>  li=(List<Map>) dataservice1.exe();
//	 	System.out.println(AtiJson.toJson(li));
	 	
 
	}
	 public static final Logger logger = LoggerFactory
				.getLogger(IocFacV3_iocx_iocutil.class);
	/**
	@author attilax 老哇的爪�?
		@since  o92 j_48_40   
	
	 * @param class1
	 * @return
	 */
	public  static  <t> t getBean(Class<t> class1) {
		if(System.getProperty("cfgfile")==null)
			throw new RuntimeException("System.getProperty(cfgfile)==null");
		 String ico_name="";
		 String cfgfile=System.getProperty("cfgfile");
		 cfgfile=	 pathx
			.webAppPath()
			+ "/"+System.getProperty("cfgfile");
		 PropX px=new PropX(cfgfile);
		 ico_name=px.getProperty("ioc");
		 
		 
 
		 if(StringUtils.isEmpty(ico_name))
			 throw new RuntimeException("cant find detail ioc cfg class,maybe prj var is not set..cfgfile:"+cfgfile);
			Object o = null;
		 try {
			  o=	 com.attilax.reflect.MethodUtils.invokeStaticMethod(ico_name, "getBean", (Object)class1);
		} catch (Exception e) {
			logger.error("--iconame:"+ico_name+",cls:"+class1.toString());
		}
	
		// attilax 老哇的爪�?  j_48_40   o92 
		 
				
		return    (t) o;
		
	}
	
	public  static  <t> t getBean(String iocName,Class<t> class1) {
		 
		// ico_name=iocName
		 
 
	 		Object o = null;
		 try {
			  o=	 com.attilax.reflect.MethodUtils.invokeStaticMethod(iocName, "getBean", (Object)class1);
		} catch (Exception e) {
			logger.error("--iconame:"+iocName+",cls:"+class1.toString());
		}
	
		// attilax 老哇的爪�?  j_48_40   o92 
		 
				
		return    (t) o;
		
	}
	//  attilax 老哇的爪�? j_48_u   o92   
	/* (non-Javadoc)
	 * @see org.directwebremoting.extend.Creator#getType()
	 * @author  attilax 老哇的爪�?
	 *@since  o93 l_d_c$
	 */
  
	/**
	@author attilax 老哇的爪�?
		@since  o02 4_f_56   
	
	 * @param string
	 */
	public static     <t> t getBean(String className) {
		// attilax 老哇的爪�?  4_f_56   o02 
		try {
			Class c=Class.forName(className);
			return (t) getBean(c);
		} catch (ClassNotFoundException e) {
			//  attilax 老哇的爪�? 4_h_t   o02   
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	//	return null;
		
	}
	
	
	public static     <t> t getBean(String iocName,String className) {
		// attilax 老哇的爪�?  4_f_56   o02 
		try {
			Class c=Class.forName(className);
			return (t) getBean(iocName,c);
		} catch (ClassNotFoundException e) {
			//  attilax 老哇的爪�? 4_h_t   o02   
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	//	return null;
		
	}
}

//  attilax 老哇的爪�?